package com.glsc.ngateway.common.base.domain.mysql.gateway.platform.flow.cmdb;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.glsc.ngateway.common.base.domain.mysql.gateway.FlowFormBaseEntity;
import lombok.*;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.time.LocalDate;

/**
 * @author zhengyr
 * @date 2023/8/2-14:44
 * 新增的memory规格明细数据
 */
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@Entity
@Where(clause = "deleted = 0")
@SQLDelete(sql = "update t_gw_flow_form_memory_out_detail set deleted = UNIX_TIMESTAMP(NOW()) where id=?")
@SQLDeleteAll(sql = "update t_gw_flow_form_memory_out_detail set deleted = UNIX_TIMESTAMP(NOW()) where id=?")
@Table(name = "t_gw_flow_form_memory_out_detail")
@org.hibernate.annotations.Table(appliesTo = "t_gw_flow_form_memory_out_detail", comment = "内存入库数据-配件入库流程子表")
public class FlowFormMemoryOutDetail extends FlowFormBaseEntity {

    @Column(name = "memory_standard_code", length = 100, columnDefinition = "varchar(100) DEFAULT NULL COMMENT '内存规格业务编码'")
    private String memoryStandardCode;

    @Column(name = "memory_detail_code", length = 100, columnDefinition = "varchar(100) DEFAULT NULL COMMENT 'memory编号'")
    private String memoryDetailCode;

    @Column(name = "part_num", length = 100, columnDefinition = "varchar(100) DEFAULT NULL COMMENT '内存规格配件号'")
    private String partNum;
//    @Column(name = "memory_standard_name", length = 100, columnDefinition = "varchar(100) DEFAULT NULL COMMENT '内存规格名称'")
//    private String memoryStandardName;

    @Column(name = "sn", length = 100, columnDefinition = "varchar(100) DEFAULT NULL COMMENT '序列号'")
    private String sn;

    @Builder.Default
    @Column(name = "life_status", columnDefinition = "tinyint DEFAULT 0 COMMENT 'PART_LIFE_CYCLE生命周期  库存，已分配，已报废，分配待确认'")
    private Integer lifeStatus=0;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @JsonSerialize(using = LocalDateSerializer.class)
    @JsonDeserialize(using = LocalDateDeserializer.class)
    @Column(name = "manufact_date", columnDefinition = "date DEFAULT NULL COMMENT '生产日期'")
    private LocalDate manufactDate;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @JsonSerialize(using = LocalDateSerializer.class)
    @JsonDeserialize(using = LocalDateDeserializer.class)
    @Column(name = "expirate_date", columnDefinition = "date DEFAULT NULL COMMENT '过保日期'")
    private LocalDate expirateDate;

    @Column(name = "location_id", columnDefinition = "int DEFAULT NULL COMMENT '位置id  库存状态是机房id\\r\\n装机状态是服务器明细id'")
    private Integer locationId;
}
